/*
*  Tools definition file
*  ======================================================================
*  NOTE: This is not a real javascript file. This file acts as the 
*        configuration file for the PIMP drawing program. Ignore apparent
*        errors in syntax.
*/ 

/*
tool=Marquee&icon=images/marquee.gif&desc=Use your mouse to outline the area you wish to edit
*/
event=_mousedown 
	var d=MM_findObj,M=d("marqpanel")
	try {
	    with (M) {
	        innerHTML     = "";
	        style.display = "none";
	        style.left    = this._x;
	        style.top     = this._y;
	        style.width   = 1;
	        style.height  = 1;
	        style.border  = "solid 1px #FF0000"; 
	    }
	} catch (ex) { }
event=_mousedown

event=_mousemove 
	var d=MM_findObj,M=d("marqpanel")
	try {
	    with (M) {
	        style.display = "inline";
	        style.width  = this._x-cx;
	        style.height = this._y-cy;
	    }
	} catch (ex) { }
event=_mousemove

event=_mouseup
	var d=MM_findObj,M=d("marqpanel"),D=d("dworkspace"),P=d("mainpic");
	try {
	    var mm = mboundary (M);
	    with (M) {
	        style.border = "solid 1px #00FF00"; 
	       // var sc = inRegion (X,Y,mm);
	        ox=mm[0];
	        oy=mm[1];
	        pw=offsetWidth;
	        ph=offsetHeight;
	        px=ox-docx(P) - D.scrollLeft
	        py=oy-docy(P) - D.scrollTop 
	        im=imageurl+"&px="+px+"&py="+py+"&pw="+pw+"&ph="+ph;
	        innerHTML = ("<img id=marqpreview src='thumbnail.php?"+im+"'>");
	    }
	} catch (ex) { }
event=_mouseup


/*
tool=Lasso&icon=images/lasso.gif&desc=Choose an option below and select the area of the image you want to affect&penspan=3&option[0]=pen,X&option[1]=color,FF0000
*/
event=_mouseup 
	var d=MM_findObj,f=d("rdolass1"),e=d("rdolass2")
	if (e.checked) this._request += "&c2=FFFFFF";
	wsdl (this._request)
	sizepic();
event=_mouseup

event=_onload 
	var html="",d=MM_findObj,ck=d("cklassotable"),bon=ck?ck.checked:true,L=d("dopt"+this._brush); 
	html += "<div align='left'>";
	html += "<input type=radio name=rdolasso id=rdolass1>Fill with selected color<br>";
	html += "<input type=radio name=rdolasso id=rdolass2 checked >Erase selection</div>"; 
	html = makepanel('lassotable', 'Lasso Options', html, bon); 
	L.innerHTML = html;
event=_onload


/*
tool=Wand&icon=images/wand.gif&desc=Choose an option below and select the area of the image you want to affect&option[0]=color,FF0000
*/
event=_mouseup 
	var d=MM_findObj,f=d("rdolass1"),e=d("rdolass2")
	if (e.checked) this._request += "&c2=FFFFFF";
	wsdl (this._request)
	sizepic();
event=_mouseup

event=_onload 
	var html="",d=MM_findObj,ck=d("ckwandtable"),bon=ck?ck.checked:true,L=d("dopt"+this._brush); 
	html += "<div align='left'>";
	html += "<input type=radio name=rdolasso id=rdolass1>Fill with selected color<br>";
	html += "<input type=radio name=rdolasso id=rdolass2 checked >Erase selection</div>"; 
	html = makepanel('wandtable', 'Wand Options', html, bon); 
	L.innerHTML = html;
event=_onload


/*
tool=Zoom&icon=images/zoom.gif&desc=Enlarge or shrink the image
*/
event=_mousedown&arguments=x,y
   var d=MM_findObj,EW=d("editworkspace"),DW=d("dworkspace"),P=mboundary (EW); 
	Px=P[0];Py=P[1];
    Rx = (X-Px)+DW.scrollLeft;
	Ry = (Y-Py)+DW.scrollTop;
//	alert (Rx+","+Ry);
event=_mousedown

event=_mouseup
	if (Hoffset==0) Hoffset = zoomval.value.replace("%","")/100;
	setoffset(Hoffset*2)
	gx=(this._x- docx(mainpic)) + dworkspace.scrollLeft
	gy=(this._y- docy(mainpic)) + dworkspace.scrollTop ;
event=_mouseup


/*
tool=Dropper&icon=images/dropper.gif&desc=Use your mouse to Select a color from the image&option[0]=color,FFFFFF
*/
event=_mouseup
	px=this._x;
	py=this._y;
	px-=docx(mainpic) - dworkspace.scrollLeft;
	py-=docy(mainpic) - dworkspace.scrollTop; 
	this._request += "&ex="+px+"&ey="+py; 
	c = (wsdl(this._request))  
	customcolor = c;
	grid (c.substr(0,2),c.substr(2,2),c.substr(4,2))
	hidestatus();
event=_mouseup  

/*
tool=Pencil&icon=images/pencil.gif&option[0]=color,000000&option[1]=pen,4&desc=Use your mouse to Draw on the image using the selected color and pen size
*/
event=_mousedown
	var d=MM_findObj,M=d("marqpanel")
	M.style.display = "none";
event=_mousedown

event=_mouseup
	showstatus ("Drawing...");
	// alert(this._request);
	wsdl(this._request);
	sizepic();
event=_mouseup


/*
tool=Eraser&icon=images/eraser.gif&option[0]=pen,8&desc=Use your mouse to Erase portions of the image using the selected pen size
*/
event=_mousedown
	var d=MM_findObj,M=d("marqpanel")
	M.style.display = "none";
event=_mousedown

event=_mouseup
	showstatus ("Erasing...");
	z = (wsdl(this._request));
	sizepic();
event=_mouseup


/*
tool=Bucket&icon=images/bucket.gif&option[0]=color,0000FF&desc=Click an area of the image to Fill with the selected color
*/
event=_mousedown
	var d=MM_findObj,M=d("marqpanel")
	if (M.style.display!="inline") {
	   if (confirm ("You cannot use this tool because no pixels are selected. You must use the Marquee Tool to select the area you wish to fill. Would you like to open the Marquee Tool now?"))
			grab ("Marquee")
	}
event=_mousedown

event=_mouseup
	var d=MM_findObj,M=d("marqpanel"),D=d("dworkspace"),P=d("mainpic"),Z=d("zoompic")
	var mm = mboundary (M);
	var sc = inRegion (X,Y,mm);
	mm[0] -= docx(P) - D.scrollLeft
	mm[1] -= docy(P) - D.scrollTop
	mm[2] -= docx(P) - D.scrollLeft
	mm[3] -= docy(P) - D.scrollTop 	
	this._request += "&d="+mm[0]+","+mm[1]+","+mm[2]+","+mm[3];	  
	wsdl(this._request);
	P.src="thumbnail.php?"+imageurl;
	Z.src=zoompic.src; 
event=_mouseup


/*
tool=Text&icon=images/text.gif&option[0]=color,0000FF&option[1]=font,3 9&desc=Click the area of the image where you want your text
*/
event=_send
	dr=true;
	pixels=new Array("0")
    showmq();
   
	mm = mboundary (marqpanel)
	
	mm[0] -= docx(mainpic) - dworkspace.scrollLeft
	mm[1] -= docy(mainpic) - dworkspace.scrollTop
     var R="",T=this._cache;
     for (e=0;e<T.length;e++) {
	    c=T.substr(e,1);
		if (c==" ") R += "+";
		else R += c;
	 }
    this._request += "&d="+mm[0]+","+mm[1]+","+R 
    alert (this._request);
	wsdl(this._request);
	mainpic.src="thumbnail.php?"+imageurl;
	zoompic.src=zoompic.src; 
    with (marqpanel) {
	   innerHTML = "";
	   style.display="none";
	}
event=_send

event=_onload
    var html="",d=MM_findObj,ck=d("ckfonttable"),bon=ck?ck.checked:true,L=d("dopt"+this._brush);  
    var F=this._font;
    var A=F.split(" ")  
   
    html += "<div style='width:180;height:60;overflow:auto;border:solid 1px gray'>"
    html += "<img border=0 src='thumbnail.php?b=Fonts&f="+A[0]+"' usemap='#fontmap'>";
    html += " </div>" 
    html += "<textarea style='width:180;height:40' id=ifonttext>"+this._cache+"</textarea><br>";
    html += "Size <input onchange='tools[SELECTEDTOOL]._change()' size=2 id=ifontsize value='"+A[1]+"'>&nbsp;" 
    html += "<input type='button' value='Apply' onclick='tools[SELECTEDTOOL]._send()'>"  

    html += "<input id=tfontname type=hidden value='"+A[0]+"'>" 
    html += "<map name='fontmap'>"
   
    for (i=-2,k=0;i<600;i+=16) { 
	    x1 = 2
	    y1 = i
	    x2 = 160
	    y2 = i+12
        html += "<area style='cursor:hand' onclick='tfontname.value=\""+k+"\";tools[SELECTEDTOOL]._change()' ";
	    html += " title='"+k+"' shape=rect coords='"+x1+","+y1+","+x2+","+y2+"'>" 
	    k++; 
    }
    html += "</map>";
   
	html = makepanel('fonttable', 'Choose font and text', html, bon); 
    L.innerHTML = html; 
    this._font = F;
event=_onload

event=_change
	var R="",T=ifonttext.value,Z=ifontsize.value,N=tfontname.value;
	this._font=N+" "+Z;
	if (marqpanel.style.display=="inline") {
		for (e=0;e<T.length;e++) {
			c=T.substr(e,1);
			if (c==" ") R += "+";
			else R += c;
		}
		pw=marqpanel.offsetWidth-2;
		ph=marqpanel.offsetHeight-2;
		F = this._font.split (" ");
		R="pw="+pw+"&ph="+ph+"&f="+F[0]+"&c="+this._color+"&m="+R+"&s="+F[1];
		marqpreview.src="thumbnail.php?"+R;
	}
	this._cache=T;
	this._onload();
event=_change



/*
tool=Crop&icon=images/clip.gif&desc=Click the area of the image that you want to crop
*/
event=_mousedown
	if (marqpanel.style.display!="inline") {
	   if (confirm ("You cannot use this tool because no pixels are selected. You must use the Marquee Tool to select the area you wish to "+this._brush+". Would you like to open the Marquee Tool now?"))
			grab ("Marquee")
	}
event=_mousedown

event=_mouseup
	var d=MM_findObj,M=d("marqpanel"),D=d("dworkspace"),P=d("mainpic"),Z=d("zoompic"),F=d("fauxpanel");
	if (confirm('Crop selection?')) {
		var mm = mboundary (M);
		// var sc = inRegion (X,Y,mm);
		mm[0] -= docx(P) - D.scrollLeft
		mm[1] -= docy(P) - D.scrollTop
		nx = ox - docx(P) - D.scrollLeft
		ny = oy - docy(P) - D.scrollTop
		nw=M.offsetWidth;
		nh=M.offsetHeight; 
		this._request += "&d="+nx+","+ny+","+nw+","+nh;	    
		alert(this._request);
		wsdl(this._request);
		P.src="thumbnail.php?"+imageurl;
		Z.src=Z.src; 
		F.style.display = "none";
		M.style.display = "none";
	}
event=_mouseup  

event=_after 
	var i = "i="+IMAGEPATH+"&ac=ac";
	actual = wsdl(i);
	actual = actual.split(","); 
	hidestatus();
event=_after	

		
/*
tool=Move&icon=images/move.gif&desc=Use your mouse to Move the selected area
*/
event=_mousedown
	if (marqpanel.style.display!="inline") {
	   if (confirm ("You cannot use this tool because no pixels are selected. You must use the Marquee Tool to select the area you wish to "+this._brush+". Would you like to open the Marquee Tool now?"))
			grab ("Marquee")
	} else {
		cx = this._x-docx(marqpanel);
		cy = this._y-docy(marqpanel);
		with (fauxpanel) {
			style.display="inline"; 
			style.top   =oy;
			style.left  =ox;
			style.width =marqpanel.offsetWidth;
			style.height=marqpanel.offsetHeight;
			style.backgroundColor="#FFFFFF";
		}
	}
event=_mousedown	  
 
event=_mousemove 
	var D = mboundary (mainpic);
	mw = this._x-cx;
	mh = this._y-cy;
	if (mw<D[0]) mw = D[0];
	if (mh<D[1]) mh = D[1];
	if (mw+marqpanel.offsetWidth>D[2]) mw = D[2] - marqpanel.offsetWidth;
	if (mh+marqpanel.offsetHeight>D[3]) mh = D[3] - marqpanel.offsetHeight;
	with(marqpanel) {			    
		style.left    = mw; 
		style.top     = mh; 
	}	 
	pixels=new Array("0");
event=_mousemove

event=_mouseup
	if (confirm('Move selection?')) {
		var mm = mboundary (marqpanel);
		var sc = inRegion (X,Y,mm);
		mm[0] -= docx(mainpic) - dworkspace.scrollLeft
		mm[1] -= docy(mainpic) - dworkspace.scrollTop
		nx = ox - docx(mainpic) - dworkspace.scrollLeft
		ny = oy - docy(mainpic) - dworkspace.scrollTop
		nw=marqpanel.offsetWidth;
		nh=marqpanel.offsetHeight;
		
		this._request += "&d="+nx+","+ny+","+mm[0]+","+mm[1]+","+nw+","+nh;	  
		
		wsdl(this._request);
		mainpic.src="thumbnail.php?"+imageurl;
		zoompic.src=zoompic.src; 
		fauxpanel.style.display = "none";
		marqpanel.style.display = "none";
	} else {
	   fauxpanel.style.display = "none";
		marqpanel.style.left = ox
		marqpanel.style.top = oy
	}
event=_mouseup   


/*
tool=Filter&icon=images/filter.gif&desc=Use the filters panel to apply filters to the image&option[0]=color,FFFFFF&option[1]=filter,8 75
*/

/* filters
filter=Negate&desc=Reverses all colors of the image. 
filter=Grayscale&desc=Converts the image into grayscale. 
filter=Brightness&desc=Changes the brightness of the image.&option=level,50
filter=Contrast&desc=Changes the contrast of the image.&option=level,50
filter=Colorize&desc=Colorize the image to the specified color.&option=color,FF0000
filter=EdgeDetect&desc=Uses edge detection to highlight the edges in the image. 
filter=Emboss&desc=Embosses the image.
filter=GaussianBlur&desc=Blurs the image using the Gaussian method. &option=level,50 
filter=Sketch&desc=Uses mean removal to achieve a 'sketchy' effect. 
filter=Smooth&desc=Makes the image smoother.&option=level,50
*/
event=_onload
    var c="",v="",html="",d=MM_findObj,ck=d("ckfxtable"),bon=ck?ck.checked:true,L=d("dopt"+this._brush);   
	var F=this._filter;
	A = F.split (" ")
	opts = "";
	eft = null;
	for (var i=0;i<effects.length;i++) {
		fkt = effects[i];
		opts += "<option value='"+i+"'";
		if (i==A[0]) {
			opts += " selected"
			eft = fkt;
			SELECTEDFILTER=i 
			v = fkt._level?A[1]:"";
			c = fkt._color?this._color:""; 
		}
		opts += ">"+fkt._name
	}
	html += "Filter: <select style='font:8pt tahoma' "
	if (c!="") html += "id=imgfilter onchange='tools[SELECTEDTOOL]._change()'>"
	else if (v!="") html += "id=imgfilter onchange='tools[SELECTEDTOOL]._change()'>"
	else html += "id=imgfilter onchange='tools[SELECTEDTOOL]._change()'>"
	html += opts + "</select>";
	if (v!="") html += "<input type=text id=imglevel size=2 value='"+v+"' onchange='tools[SELECTEDTOOL]._change()'>"
	html += "<br>" 
	if ((c=="")&&(v==""))v=0
	html += "<div align=center style=padding:2px><img onload=gozoom() src='thumbnail.php?i="+IMAGEPATH+"&w=140&l="+A[0]+"&v="+v+"&c="+c+"' align=absmiddle>";
	html += "<br><a href='javascript:tools[SELECTEDTOOL]._send()' style=color:blue><u>Apply "+eft._name+" filter</u></a></div>"; 
	html = makepanel('fxtable', 'Filter Options', html, bon);  
	this._cache = "l="+A[0]+"&v="+v+"&c="+c;
	L.innerHTML = html;
	gozoom();
	this._filter = F;
event=_onload

event=_send
	var i=imageurl+"&"+this._cache+"&z=0,0&t=Filter&d="+this._filter;
	wsdl(i);
	mainpic.src="thumbnail.php?"+imageurl;
	zoompic.src=zoompic.src; 
event=_send

event=_change 
	var d=MM_findObj,w=d("imgfilter"),x=d("imglevel"),a=0,b=0;  
	b="";
	if (x) b=x.value; 
	this._filter=w.value+" "+b; 
	this._onload(); 
event=_change


/*
tool=Rotate&icon=images/rotate.gif&desc=Use the rotation panel to rotate the image&option[0]=rotate,1 90
*/
event=_onload
    var c="",v="",html="<div align='left'>",d=MM_findObj,ck=d("ckrotatetable"),bon=ck?ck.checked:true,L=d("dopt"+this._brush);  
	P=this._rotate; 
	var A=P.split(" "); 
	
 
	html += "<img align=left src=images/rotate.gif>";
	html += "<input type=radio "+chk(A[0]==-1)+" onclick='tools[SELECTEDTOOL]._change()' id=rtway value='-1' name=rtway>Counter-clockwise<br>";
	html += "<input type=radio "+chk(A[0]==1)+" onclick='tools[SELECTEDTOOL]._change()' id=rtway value='1' name=rtway>Clockwise<br>";
	html += "<input type=radio "+chk(A[1]==90)+"  onclick='rtxamt.value=90;tools[SELECTEDTOOL]._change()' id=rtamt value=90 name=rtamt>90";
	html += "<input type=radio "+chk(A[1]==180)+" onclick='rtxamt.value=180;tools[SELECTEDTOOL]._change()' id=rtamt value=180 name=rtamt>180";
	html += "<input type=radio "+chk(A[1]==270)+" onclick='rtxamt.value=270;tools[SELECTEDTOOL]._change()' id=rtamt value=270 name=rtamt>270";
	html += "&nbsp;Custom<input size=2 id='rtxamt' value='"+A[1]+"' name='rtxamt'><br>";
	html += "&nbsp;Flip:&nbsp;<a href='javascript:window.flip(0)' style='color:blue'><u>Vertical</u></a> |";
	html += " <a href='javascript:window.flip(1)' style='color:blue'><u>Horizontal</u></a>";
	html += "<div align=right><input type='button' value='Apply' onclick='tools[SELECTEDTOOL]._send()'></div>";
	 
	
	html = makepanel('rotatetable', 'Choose rotation', html, bon);  
	
	this._rotate = P;
	
	window.flip = function (way) {
		var i=imageurl+"&z=0,0&t="+tools[SELECTEDTOOL]._brush +"&d="+(way==0?"FV":"FH");   
		// alert(i);
		wsdl(i);
		sizepic();  
	}
	
	L.innerHTML = html;
event=_onload

event=_send
	var i=imageurl+"&z=0,0&t="+this._brush +"&d="+this._rotate.replace(" ",",");
	wsdl(i);
	sizepic(); 
event=_send

event=_change 
	var d=MM_findObj,w=d("rtway"),x=d("rtxamt"),a=0,b=0;  
	for (var i=0;i<w.length;i++) { if (w[i].checked) a=w[i].value; }  
	this._rotate=a+" "+x.value; 
	this._onload(); 
event=_change

event=_after 
	var i = "i="+IMAGEPATH+"&ac=ac";
	actual = wsdl(i);
	actual = actual.split(","); 
	hidestatus();
event=_after		

	
/*
tool=Scale&icon=images/scale.gif&desc=Function not implemented&option[0]=cache,1 C PX -1 100
*/
event=_onload
    var c="",v="",html="<div align='left'>",d=MM_findObj,ck=d("ckresizetable"),bon=ck?ck.checked:true,L=d("dopt"+this._brush);  
	var MP=d("mainpic")
	P=this._cache; 
	
	var A=P.split(" ");
	var iw=MP.width
	var ih=MP.height
	var cw=CACHEDIMAGE.width
	var ch=CACHEDIMAGE.height
	sc_type=A[0];sc_align=A[1];sc_scale=A[2];sc_siz1=A[3];sc_siz2=A[4];
	if (sc_siz1==-1) {
	    sc_siz1 = parseInt((ih/ch)*100)
		sc_w = iw
		sc_h = ih
	}  else { 
	    sc_size = sc_siz1.split("/");
		sc_w = sc_size[0]
		sc_h = sc_size[1] 
	} 
	
	html += "<img align=left src=images/scale.gif>";
	html += "<input type=radio "+chk(sc_type==0)+" onclick='tools[SELECTEDTOOL]._change()' id=rscanv value='0' name=rscanv>Canvas size<br>";
	html += "<input type=radio "+chk(sc_type==1)+" onclick='tools[SELECTEDTOOL]._change()' id=rscanv value='1' name=rscanv>Image size<br>"; 
	

	html += "<input type='hidden' value='"+sc_align+"' id='rsalign'>";
	html += "<input type=radio "+chk(sc_scale=='PX')+" onclick='tools[SELECTEDTOOL]._change()' id=rssize value='PX' name=rssize>Pixels:<br>"; 
	html += "&nbsp;&nbsp;&nbsp;Width<input "+dsa(sc_scale=='PC')+" size=4 id='rsw' value='"+sc_w+"' name='rsw' onkeyup='window.justif(0)'>";
	html += "&nbsp;Height<input "+dsa(sc_scale=='PC')+" size=4 id='rsh' value='"+sc_h+"' name='rsh' onkeyup='window.justif(1)'><br>";
	
    if (sc_type==0) {
	  drs = new Array("NW","N","NE","W","C","E","SW","S","SE")
	  html += "<table align=center cellpadding=0 cellspacing=1 bgcolor=gray>";
	    for (var t0=0,t1=0;t1<3;t1++) {
		   html += "<tr>";
			for (t2=0;t2<3;t2++) {
			   bg = drs[t0]==sc_align?"yellow":"white"
		       html += "<td bgcolor='"+bg+"'><a href=\"javascript:rsalign.value='"+drs[t0]+"';tools[SELECTEDTOOL]._change()\">";
			   html += "<img border=0 src='index.php?i=px' width='24'></a>";
		       html += "</td>";
			    t0 ++;
			} 
		   html += "</tr>";
		}
		html += "</table>";
	}	
	
	html += "<input type=radio "+chk(sc_scale=='PC')+" onclick='tools[SELECTEDTOOL]._change()' id=rssize value='PC' name=rssize>Percent:";  
	html += "&nbsp;<input size=4 onchange='tools[SELECTEDTOOL]._change()' id='rsp' "+dsa(sc_scale=='PX')+" value='"+sc_siz2+"%' name='rsp'><br>";
	html += "<div align=right>"; 
	html += "<input type='button' value='Apply' onclick='tools[SELECTEDTOOL]._send()'></div></div>";
	
	
	html = makepanel('resizetable', 'Resize', html, bon);  
	window.justif = function (i) {
		var P=tools[SELECTEDTOOL]._cache; 
		var A=P.split(" "); 
		var d=MM_findObj,w=d("rsw"),h=d("rsh"); 
		ratio = CACHEDIMAGE.width/CACHEDIMAGE.height;   
		nh    = parseInt(w.value/ratio); 
		nw    = parseInt(ratio*h.value);
		if (i==0) h.value = nh;
		else w.value = nw;
	    sc_type=A[0];sc_align=A[1];sc_scale=A[2];sc_siz1=A[3];sc_siz2=A[4];  
		sc_siz1 = w.value+"/"+h.value;
	    tools[SELECTEDTOOL]._cache = sc_type+" "+sc_align+" "+sc_scale+" "+sc_siz1+" "+sc_siz2; 
	}
	
	
 
	
	this._cache=P;
	L.innerHTML = html;
	hidestatus()
event=_onload

event=_change 
	P=this._cache; 
	var A=P.split(" "); 
	var cw=mainpic.width;
	var ch=mainpic.height;
	var d=MM_findObj,st=d("rscanv"),sc=d("rssize"),sp=d("rsp"),sw=d("rsw"),sh=d("rsh"); 
	sc_type=A[0];sc_align=d("rsalign").value;sc_scale=A[2];sc_siz1=A[3];sc_siz2=A[4];  
	 for (var i=0;i<st.length;i++) { if (st[i].checked) sc_type=st[i].value; }  
	 for (var i=0;i<sc.length;i++) { if (sc[i].checked) sc_scale=sc[i].value; }   
	 sc_siz1 = sw.value+"/"+sh.value;
	 sc_siz2 = sp.value.replace("%","");  
	 if (sc_scale=="PC") {
		 s1=parseInt((actual[0]*(sc_siz2/100)));
		 s2=parseInt((actual[1]*(sc_siz2/100)));
		 sc_siz1 = s1+"/"+s2;
	 } 
		 
	 this._cache = sc_type+" "+sc_align+" "+sc_scale+" "+sc_siz1+" "+sc_siz2; 
	 this._onload();
event=_change

event=_send
	dr=true;
	pixels=new Array("0");
    showmq();
	Hoffset = 1;
	this._request+="&d="+this._cache;
    alert (this._request);
    wsdl (this._request);
	sizepic();
event=_send 

event=_after
	var d=MM_findObj,st=d("rscanv"),sc=d("rssize"),sw=d("rsw"),sh=d("rsh"),sp=d("rsp");  
	var i = "i="+IMAGEPATH+"&ac=ac";
	actual = wsdl(i);
	actual = actual.split(",");
	sp.value="100%";
	hidestatus();
event=_after			
  

/*
tool=Rect&icon=images/rect.gif&desc=Function not implemented&option[0]=color,00FF00&option[1]=stroke,00FF00&option[2]=fill,0
*/
event=_mousedown 
	var d=MM_findObj,M=d("marqpanel")
	try {
	    with (M) {
	        innerHTML     = "";
	        style.display = "none";
	        style.left    = this._x;
	        style.top     = this._y;
	        style.width   = 1;
	        style.height  = 1;
	        style.border  = "solid 1px #FFFF00"; 
	    }
	} catch (ex) { }
event=_mousedown

event=_mousemove 
	var d=MM_findObj,M=d("marqpanel")
	try {
	    with (M) {
	        style.display = "inline";
	        style.width  = this._x-cx;
	        style.height = this._y-cy;
	    }
	} catch (ex) { }
event=_mousemove

event=_mouseup 
	var d=MM_findObj,M=d("marqpanel"),D=d("dworkspace"),P=d("mainpic");
	try {
	    var mm = mboundary (M);
	    with (M) {
	        style.border = "solid 1px #00FF00";   
	        px=mm[0]-docx(P)-D.scrollLeft;
	        py=mm[1]-docy(P)-D.scrollTop;
	        pw=mm[2]-docx(P)-D.scrollLeft;
	        ph=mm[3]-docy(P)-D.scrollTop;
            this._request += "&d="+px+","+py+","+pw+","+ph
	        alert (this._request)
	        wsdl (this._request)
	        sizepic();
	    }
	} catch (ex) { }
event=_mouseup
/*
#tool=Line&icon=images/linetool.gif&desc=Function not implemented&option[0]=color,00FF00&option[1]=stroke,00FF00
*/
event=_mousedown 
	var d=MM_findObj,M=d("marqpanel")
	try {
	    with (M) {
	        innerHTML     = "";
	        style.display = "none";
	        style.left    = this._x;
	        style.top     = this._y;
	        style.width   = 1;
	        style.height  = 1;
	        style.border  = "solid 1px #FF00FF"; 
	    }
	} catch (ex) { }
event=_mousedown

event=_mousemove 
	var d=MM_findObj,M=d("marqpanel")
	try {
	    with (M) {
	        style.display = "inline";
	        style.width  = this._x-cx;
	        style.height = this._y-cy;
	    }
	} catch (ex) { }
event=_mousemove

event=_mouseup 
	var d=MM_findObj,M=d("marqpanel"),D=d("dworkspace"),P=d("mainpic");
	try {
	    var mm = mboundary (M);
	    with (M) {
	        style.border = "solid 1px #0000FF";   
	        px=mm[0]-docx(P)-D.scrollLeft;
	        py=mm[1]-docy(P)-D.scrollTop;
	        pw=mm[2]-docx(P)-D.scrollLeft;
	        ph=mm[3]-docy(P)-D.scrollTop;
            this._request += "&d="+px+","+py+","+pw+","+ph
	        alert (this._request)
	        wsdl (this._request)
	        sizepic();
	    }
	} catch (ex) { }
event=_mouseup

/*
tool=Oval&icon=images/oval.gif&desc=Use your mouse to draw an oval on the image&option[0]=color,0000FF&option[1]=stroke,00FF00&option[2]=fill,0
*/
event=_mousedown 
	var d=MM_findObj,M=d("marqpanel")
	try {
	    with (M) {
	        innerHTML     = "";
	        style.display = "none";
	        style.left    = this._x;
	        style.top     = this._y;
	        style.width   = 1;
	        style.height  = 1;
	        style.border  = "solid 1px #FF00FF"; 
	    }
	} catch (ex) { }
event=_mousedown

event=_mousemove 
	var d=MM_findObj,M=d("marqpanel")
	try {
	    with (M) {
	        style.display = "inline";
	        style.width  = this._x-cx;
	        style.height = this._y-cy;
	    }
	} catch (ex) { }
event=_mousemove

event=_mouseup 
	var d=MM_findObj,M=d("marqpanel"),D=d("dworkspace"),P=d("mainpic");
	try {
	    var mm = mboundary (M);
	    with (M) {
	        style.border = "solid 1px #0000FF";   
	        px=(mm[0]-docx(P)-D.scrollLeft)+(mm[4]/2);
	        py=(mm[1]-docy(P)-D.scrollTop)+(mm[5]/2);
	        pw=mm[2]-docx(P)-D.scrollLeft;
	        ph=mm[3]-docy(P)-D.scrollTop;
            this._request += "&d="+px+","+py+","+mm[4]+","+mm[5]
	        alert (this._request)
	        wsdl (this._request)
	        sizepic();
	    }
	} catch (ex) { }
event=_mouseup

/* 
menu=media&for=t
icon=x&caption=&action=javascript:history.back()
icon=q&caption=&action=javascript:location.reload()
caption=-
icon=d&caption=Save&action=javascript:document.forms[0].save()
caption=&icon=g&action=javascript:fb_edit("fo","on")&qfilter=fo&title=Show Folders
caption=&icon=g&action=javascript:fb_edit("fo","")&qfilter=fo&qvalue=on&title=Hide Folders&style=background-color:white;border:inset 1px
menu=media
menu=media&for=b
icon=x&caption=&action=javascript:history.back()
icon=s&caption=&action=javascript:getParent()
icon=q&caption=&action=javascript:location.reload()
caption=-
options=View As&option[0]=Details,v,d,r,on&option[1]=Filmstrip,v,,r,on&option[2]=Thumbnails,v,t,r,on&ppc=no&bkb=no
caption=-&ftype=,jpg,gif,png&ppc=no&bkb=no
icon=pm&caption=Edit&action=javascript:fb_edit("e", "t")&ftype=,txt,&ppc=no&bkb=no&qfilter=e&qvalue=b
icon=pm&caption=Exit Edit Mode&action=javascript:fb_edit("e", "")&ftype=,txt&ppc=no&bkb=no&qfilter=e&qvalue=t
icon=pm&caption=Edit&action=javascript:fb_edit("e", "e", "r", "on", "v", "", "hm", "")&ftype=,jpg,gif,png&ppc=no&bkb=no
icon=pf&caption=Slideshow&action=javascript:fb_edit("v","s","pv","on","r","on")&ftype=,jpg,gif,png&ppc=no&bkb=no&qfilter=v
icon=pf&caption=Exit&action=javascript:fb_edit("v","")&ftype=,jpg,gif,png&ppc=no&bkb=no&qfilter=v&qvalue=s&style=background-color:white;border:inset 1px
caption=-&ftype=,jpg,gif,png&ppc=no&bkb=no
title=Size To Fit&icon=pe&action=javascript:fb_edit("r","on")&ftype=,jpg,gif,png&qfilter=r&ppc=no&bkb=no
title=Normal Size&icon=pe&action=javascript:fb_edit("r","")&ftype=,jpg,gif,png&qfilter=r&qvalue=on&ppc=no&bkb=no&style=background-color:white;border:inset 1px
options=Size&icon=pw&option[0]=1x,mz,1&option[1]=2x,mz,2&ftype=,nsv&ppc=no&bkb=no
options=Size&icon=py&option[0]=1x,mz,1&option[1]=2x,mz,2&ftype=,ram &ppc=no&bkb=no
caption=-&ppc=no&bkb=no&ftype=,nsv,ram
caption=&icon=t&action=javascript:fb_edit("pv","on")&qfilter=pv&style=background-color:white;border:inset 1px&title=Hide Preview
caption=&icon=t&action=javascript:fb_edit("pv","")&qfilter=pv&qvalue=on&title=Show Preview
caption=-&ppc=no&bkb=no&ftype=,jpg,gif,png
icon=v&ftype=,jpg,gif,png&ppc=no&bkb=no&action=javascript:fb_edit("dg","on")&qfilter=dg&title=Show Drawing Grid
icon=v&ftype=,jpg,gif,png&ppc=no&bkb=no&action=javascript:fb_edit("dg","")&qfilter=dg&qvalue=on&style=border:inset 1px&title=Hide Drawing Grid
caption=&icon=g&action=javascript:fb_edit("fo","on")&qfilter=fo&title=Show Folders
caption=&icon=g&action=javascript:fb_edit("fo","")&qfilter=fo&qvalue=on&title=Hide Folders&style=background-color:white;border:inset 1px
caption=&icon=n&action=javascript:fb_edit("j","m")&qfilter=j&title=Enter Admin Mode
caption=&icon=n&action=javascript:fb_edit("j","")&qfilter=j&qvalue=m&title=Exit Admin Mode&style=background-color:white;border:inset 1px
caption=&icon=pu&action=javascript:snapshot()&title=Snapshot
menu=media

*/